//重试几次请求，都失败就报错
//fetchXXXData请求方法
//retryTimes重试次数
export const retryFunc = (fetchData, numberOfRetry) => {
return new Promise((resolve, reject) => {
  return fetchData.then(result => {
    
    resolve(result)
  }).catch(error => {
    if(numberOfRetry > 0){  
        numberOfRetry = numberOfRetry - 1
        console.log(numberOfRetry)
          retryFunc(fetchData, numberOfRetry)
    } else {
    reject(error)
        }
  })
})}
//调用方法
// retryFunc(new Promise((rev, rej) => rev(6)), 3)
//         .then(res => console.log(res))

// retryFunc(new Promise((rev, rej) => rej(6)), 3).then(res => console.log(res))
